package api

import (
	"api-gatwary/basic/globar"
	__ "api-gatwary/basic/proto"
	"api-gatwary/handler/request"
	"net/http"

	"github.com/gin-gonic/gin"
)

func Shopadd(c *gin.Context) {
	var req request.ShopReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusInternalServerError, gin.H{
			"code":    http.StatusInternalServerError,
			"message": err.Error(),
			"data":    false,
		})
		return
	}
	shopadd, err := globar.Clients.Shopadd(c, &__.ShopaddReq{
		Name:        req.Name,
		Description: req.Description,
		Sort:        req.Sort,
	})
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code":    http.StatusBadRequest,
			"message": err.Error(),
			"data":    false,
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code":    http.StatusOK,
		"message": "添加成功",
		"data":    shopadd,
	})
}
